<?php
$this->Html->scriptBlock($script, array('inline' => false));
$this->Html->scriptBlock($windowsscript, array('inline' => false));
?>
<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<?php
$formUrl = array('controller' => 'aihexpenses', 'action' => 'edit');
echo $this->Form->create('Aihexpense', array('url' => $formUrl, 'type' => 'text'));
echo $this->Form->input('id');
?>

<div class="wrapper-content-body clearfix">
    <div class="wrapper-form clearfix">
        <div class="wrapper-aih-expense-ref ">
            <span class="size-span"><?php echo __('Acc resume related'); ?> :</span>
            <input type="checkbox" id="AccResumeRelated" name="AccResumeRelated" value="1" <?php echo ($this->data['Aihexpense']['acc_resume_related'] == 1)? 'checked': ''; ?> disabled />
        </div>
        <div class="wrapper-aih-expense-ref ">
            <span class="size-span"><?php echo __('Reference#'); ?> :</span>
            <span class=""><?php echo __($this->data['Aihexpense']['refid_edit']); ?></span>
        </div>
        <div class="line-form-aih" id="paymentdetail">
            <span class="size-span"><?php echo __('Payment Schedule #'); ?> :</span>
            <span class=""><?php echo __($this->data['Aihexpense']['paydetailid']); ?></span>
            <?php
            echo $this->Form->input('paydetailid', array('type' => 'hidden' ,'label' => false,'div' => false, 'value' => $this->data['Aihexpense']['paydetailid'], 'readonly' => 'readonly'));
            ?>
        </div>
        <div class="line-form-aih">
            <span class="size-span"><?php echo __('Date'); ?> (*):</span> 
            <?php
            echo $this->Form->text('date', array(
                'value' => date('m/d/Y', strtotime($this->data['Aihexpense']['date'])),
                'class' => 'sel-date',
                'readonly' => 'readonly',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>
        <div class="line-form-aih clearfix">
            <span class="size-span"><?php echo __('Reference of Transaction'); ?> (*):</span>
            <?php
            echo $this->Form->text('reference_of_transaction', array(
                'value' => $this->data['Aihexpense']['reference_of_transaction'],
                'class' => 'aih-expense-amount-number',
                'label' => false,
                'style' => 'width: 300px;',
                'div' => false,)
            );
            ?>
            <span style="font-style: italic;">Your Bank supplied you after transaction completed.</span>
        </div>
        <div class="line-form-aih clearfix">
            <span class="size-span"><?php echo __('From'); ?> (*):</span>
            <?php
            echo $this->Form->textarea('from', array(
                'value' => $this->data['Aihexpense']['from'],
                'class' => 'aih-expense-textarea-from',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>

        <div class="line-form-aih clearfix">
            <span class="size-span"><?php echo __('To'); ?> (*):</span>
            <?php
            echo $this->Form->textarea('to', array(
                'value' => $this->data['Aihexpense']['to'],
                'class' => 'aih-expense-textarea-from',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>

        <div class="line-form-aih">
            <span class="size-span"><?php echo __('Amount'); ?> (*):</span>
            <?php
            echo $this->Form->text('amount', array(
                'value' => $this->data['Aihexpense']['amount'],
                'class' => 'aih-expense-amount-number',
                'label' => false,
                'div' => false,)
            );
            ?>
            <?php
            echo $this->Form->input('Currency.Currency', array(
                'multiple' => false,
                'empty' => false,
                'selected' => $this->data['Aihexpense']['currency_id'],
                'class' => '',
                'label' => false,
                'div' => false,)
            );
            ?>
            <?php
            echo $this->Form->text('amount_note', array(
                'value' => $this->data['Aihexpense']['amount_note'],
                'class' => 'aih-expense-amount-char',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>

        <div class="line-form-aih clearfix">
            <span class="size-span"><?php echo __('Description'); ?> :</span>
            <?php
            echo $this->Form->textarea('description', array(
                'value' => $this->data['Aihexpense']['description'],
                'class' => 'aih-expense-textarea-description',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>
        <div class="line-form-aih">
            <span class="size-span"><?php echo __('Charge Payer'); ?> :</span>
            <input type="hidden" name="oldContactID" value="<? echo $this->data['Aihexpense']['charge_payer'] ?>" />
            <?php
            echo $this->Form->input('Aihcontact.Aihcontact', array(
                'multiple' => false,
                'selected' => $this->data['Aihexpense']['charge_payer'],
                'empty' => false,
                'class' => 'sel-ref-aih-expense',
                'label' => false,
                'div' => false,)
            );
            ?>

        </div>
    </div>
</div>

<!-- HTML for buttom -form-->
<div class="wrapper-button-form">
    <div class="button-form">
        <div class="button-aihre button-blue"><a href="#" class="save">SAVE</a></div>
        <div class="button-aihre button-blue"><?php echo $this->Html->link(__('CANCEL'), array('plugin' => null, 'controller' => 'aihexpenses', 'action' => 'index')); ?></div>
        <div class="button-aihre button-blue">
            <?php
            echo $this->Html->link(__('DELETE'), array(
                'controller' => 'aihexpenses',
                'action' => 'delete',
                $this->data['Aihexpense']['id'],
                'token' => $this->params['_Token']['key'],), null, __('Are you sure you want to delete this Expense?'));
            ?>
        </div>
        <div class="button-aihre button-blue"><a href="#" class="aihexpense_report">REPORT</a></div>
    </div>
</div>
<?php
echo $this->Form->end();
?>
<?php
$validForm = "
    $(function(){
        $('#AihexpenseAmount').change(function(){
            $('#AihexpenseAmount').formatCurrency();
        });
        $('#AihexpenseAdminEditForm').ready(function(){
            $('#AihexpenseAmount').formatCurrency();
        });
        
        $('#AihexpenseAmount').blur(function(){
            $('#AihexpenseAmount').formatCurrency();
        });
        $('a.save').click(function(){
            if($('#AihexpenseReferenceOfTransaction').val() == ''){
                alert('Reference of Transaction field not allow null.');
                $('#AihexpenseReferenceOfTransaction').focus();
            }
            else if($('#AihexpenseFrom').val() == ''){
                alert('From field not allow null.');
                $('#AihexpenseFrom').focus();
            }else if($('#AihexpenseAmount').val() == ''){
                alert('Amount field not allow null.');
                $('#AihexpenseAmount').focus();
            }else{
                $('#AihexpenseAdminEditForm').submit();
            }
        });
    });";
$this->Html->scriptBlock($validForm, array('inline' => false));
?>